<template>
  <div class="container">
    <el-table :data="tableData" style="width: 100%" :fit='true'>
      <el-table-column prop="createTime" label="应聘日期">
      </el-table-column>
      <el-table-column prop="jobName" label="职位">
      </el-table-column>
      <el-table-column prop="statusText" label="状态">
      </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="page" :page-sizes="[10, 20, 30, 40]" :page-size="size"
        layout="prev, pager, next, jumper, sizes, total" :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { jobCondition } from '../../../api/resume'
export default {
  name: '',
  data () {
    return {
      page: 1,
      size: 10,
      total: 0,
      tableData: []
    }
  },
  props: ['resumeId'],
  created () {
    console.log(this.resumeId);

    this.getCondition();
  },
  watch: {
    resumeId: function () {
      this.page = 1;
      this.size = 10;
      this.getCondition();
    }
  },
  methods: {
    getCondition () {
      let query = new FormData;
      query.append('id', this.resumeId)
      query.append('page', this.page)
      query.append('size', this.size)

      console.log(query);

      jobCondition(query).then(res => {
        if (res.success) {
          this.tableData = res.data.records || []
          this.total = res.data.total;
        } else {
          this.$message.error(`${res.msg}`)
        }
      })
    },
    handleSizeChange (val) {
      this.size = val
      this.getCondition();
    },
    handleCurrentChange (val) {
      this.page = val
      this.getCondition()
    },
  }
}
</script>

<style lang="css" scoped>
.page {
    text-align: center;
    margin-top: 10px;
}
.el-table /deep/ td,
.el-table /deep/ th {
    text-align: center;
}
</style>